package com.bdqn.qnnews.search.vo;

import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.util.Date;

@Data
@Schema(name = "用户搜索请求 vo")
public class UserSearchReqVo {

    @Schema(description = "机器id")
    private Integer equipmentId;

    @Schema(description = "搜索关键字")
    private String searchWords;

    @Schema(description = "当前页码")
    private int pageNum = 0;

    @Schema(description = "每页显示条数")
    private int pageSize = 10;

    @Schema(description = "频道名称")
    private String tag;

    @Schema(description = "最小时间")
    private Date minBehotTime;

    /**
     * 获取分页起始数据
     * @return
     */
    @JsonIgnore
    public int getFromIndex(){
        if(this.pageNum<1) {
            return 0;
        }
        if(this.pageSize<1) {
            this.pageSize = 10;
        }
        return this.pageSize * (pageNum-1);
    }
}